package com.health.work.parse;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

import com.health.work.model.AddressBean;
import com.health.work.model.TypeBean;
import com.health.work.utils.DefaultJSONData;

public class TypeParse implements DefaultJSONData {
	public ArrayList<TypeBean> typeListCertificateType;
	public List<String> nameListCertificateType;
	public ArrayList<TypeBean> typeListProfessionalCategory;
	public List<String> nameListProfessionalCategory;
	public ArrayList<TypeBean> typeListBusinessType;
	public List<String> nameListBusinessType;
	@Override
	public void parse(JSONArray array) throws JSONException {
//		[{"Id":1,"Name":"药品零售店"},{"Id":2,"Name":"个体诊所"}]
		Log.e("TypeParse", array.toString());
		if(array.length()>0){
			typeListBusinessType=new ArrayList<TypeBean>();
			nameListBusinessType=new ArrayList<String>();
			for(int i=0;i<array.length();i++){
				TypeBean p=new TypeBean();
				p.TypeId=array.getJSONObject(i).getString("Id");
				p.TypeName=array.getJSONObject(i).getString("Name");
				nameListBusinessType.add(p.TypeName);
				typeListBusinessType.add(p);
			}
		}
	}

	@Override
	public void parse(JSONObject object) throws JSONException {
//		 {"professional":[{"Name":"内科","Id":1},{"Name":"外科","Id":2}],"certificate":[{"Name":"执业医师","Category":"执业类","Id":1},{"Name":"主任医师","Category":"职称类","Id":2}]}
		Log.e("TypeParse", object.toString());
		if(object.length()>0){
			if(object.isNull("professional")){

			}else{
				
				JSONArray professional=object.getJSONArray("professional");
				if(professional.length()>0){
					typeListProfessionalCategory=new ArrayList<TypeBean>();
					nameListProfessionalCategory=new ArrayList<String>();
					for(int i=0;i<professional.length();i++){
						TypeBean p=new TypeBean();
						p.TypeId=professional.getJSONObject(i).getString("Id");
						p.TypeName=professional.getJSONObject(i).getString("Name");
						nameListProfessionalCategory.add(p.TypeName);
						typeListProfessionalCategory.add(p);
					}
				}
				
				JSONArray certificate=object.getJSONArray("certificate");
				if(certificate.length()>0){
					typeListCertificateType=new ArrayList<TypeBean>();
					nameListCertificateType=new ArrayList<String>();
					for(int i=0;i<certificate.length();i++){
						TypeBean p=new TypeBean();
						p.TypeId=certificate.getJSONObject(i).getString("Id");
						p.TypeName=certificate.getJSONObject(i).getString("Name");
						nameListCertificateType.add(p.TypeName);
						typeListCertificateType.add(p);
					}
				}
			}
			
		}
	}

	@Override
	public void parse(String result) throws JSONException {
		
	}

}
